/**
 * @AStruts2Example.as
 * 
 * @author sodaChen mail:asframe@163.com
 * @version 1.0
 * <br>Copyright (C), 2010 asFrame.com
 * <br>This program is protected by copyright laws.
 * <br>Program Name:AStruts2
 * <br>Date:2012-5-9
 */
package
{
	import com.asframe.astruts2.AStrutst2Init;
	import com.asframe.astruts2.context.IAStrutsContext;
	import com.asframe.astruts2.example.LoginMediator;
	import com.asframe.astruts2.example.NoticeFilterObj;
	import com.asframe.astruts2.interfaces.impl.SpriteRootContainer;
	import com.asframe.log4a.LoggerFactory;
	
	/**
	 * AStruts2的简单例子
	 * @author sodaChen
	 * @Date:2012-5-9
	 */
	public class AStruts2Example extends SpriteRootContainer
	{
		private var loginMediator:LoginMediator;
		private var noticeFilterObj:NoticeFilterObj;
		
		private var astrutsInit:AStrutst2Init;
		private var context:IAStrutsContext;
		public function AStruts2Example()
		{
			super();
			astrutsInit = new AStrutst2Init(this);
			context = astrutsInit.initAstruts(onComplete);
			
			//单独测试apply的性能
//			var t:Number = getTimer();
//			for (var i:int = 0; i < 10000; i++) 
//			{
//				testApply("soda",18);
//			}
//			trace("正常调用花费时间:" + (getTimer() - t));
//			
//			var ary:Array = ["soda",18];
//			t = getTimer();
//			for (var j:int = 0; j < 10000; j++) 
//			{
//				testApply.apply(this,ary);
//			}
//			trace("正常调用花费时间:" + (getTimer() - t));
		}
		private function onComplete():void
		{
			context.registerBean("this is AStruts2","astruts");
			context.sendNotice(LoginMediator.OPEN_LOGIN,"soda");
			context.sendNotice(LoginMediator.CLOSE_LOGIN,"suving");
			context.sendNotice(LoginMediator.UPDATA,"asframe");
//			context.sendNotice(LoginMediator.NOTICE,[],100.111);
		}
		
		public function testApply(name:String,age:int):void
		{
			
		}
	}
}
